import java.util.Scanner;

/**
 * @author gao
 * @date 2025/9/23 8:22
 */

public class Solution {
    public String longestPalindrome(String s) {
        int n = s.length(), start = 0, end = 0;
        for (int i = 0; i < n; i++) {
            // 奇数长度回文串
            int len1 = expandCenter(s, i, i);
            // 偶数长度回文串
            int len2 = expandCenter(s, i, i + 1);

            int len = Math.max(len1, len2);
            if (len > end - start) {
                start = i - (len - 1) / 2;
                end = i + len / 2;
            }
        }
        return s.substring(start, end + 1);
    }

    private int expandCenter(String s, int left, int right) {
        // 从中心向两边扩展，直到不是回文串
        while (left >= 0 && right < s.length() && s.charAt(left) == s.charAt(right)) {
            left--;
            right++;
        }

        // 返回回文串长度
        return right - left - 1;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String s = in.nextLine();
            Solution solution = new Solution();
            System.out.println(solution.longestPalindrome(s));
        }
    }
}